const initState = {
    startCity: '',
    arriveCity: '',
    preOrderInfo: null,
}

// 声明 actionCreator
const actions = {
    changeStartCity(payload) {
        return { type:'changeStartCity',payload }
    },
    changeArriveCity(payload) {
        return { type:'changeArriveCity',payload }
    },
    setPreOrderInfo(payload) {
        return { type:'setPreOrderInfo',payload }
    },
    
}


const reducer = (state=initState,action)=>{

    const newState =  {...state }

    const { type } = action;

    switch (type){
        case 'changeStartCity':
            newState.startCity = action.payload;
            break
        case 'changeArriveCity':
            newState.arriveCity = action.payload;
            break
        case 'setPreOrderInfo':
            newState.preOrderInfo = action.payload;
            break
        default:

    }
    return newState

}

export  const  { changeStartCity,changeArriveCity,setPreOrderInfo} = actions
export  default  reducer
